﻿<sdk:Page 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
                  xmlns:tlk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
		   xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
		   xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
		    x:Class="CandyNx.SettingsPage"
                xmlns:mlight="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL5"
           mc:Ignorable="d"
           d:DesignWidth="868" d:DesignHeight="926.55"
           Title="Settings" DataContext="{Binding Source={StaticResource Locator}, Path=Settings}">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <mlight:EventToCommand Command="{Binding Load}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <sdk:Page.Resources>
        <DataTemplate x:Key="DataTemplateProjectUser">
            <Grid ShowGridLines="False" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" MinHeight="0"/>
                    <RowDefinition Height="Auto" MinHeight="0"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto" MinWidth="0"/>
                </Grid.ColumnDefinitions>

                <TextBlock Margin="8,0,0,4" TextWrapping="Wrap" Text="{Binding Username}" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="16"/>
                <Button ToolTipService.ToolTip="Delete User" Grid.Column="2" Margin="0,4,8,0" VerticalAlignment="Center" HorizontalAlignment="Right" Command="{Binding Source={StaticResource Locator}, Path=Settings.DeleteProjectUser}" CommandParameter="{Binding}" Style="{StaticResource IconButton}" Visibility="{Binding Settings.IsEditingProjectUser, Converter={StaticResource VisibilityConverter}, Source={StaticResource Locator}}" >
                    <Image Stretch="None" Source="Images/Icons/User-Delete.png"/>
                </Button>
                <StackPanel  Grid.Row="1" Orientation="Horizontal" Margin="8,0,0,0" >
                    <RadioButton IsEnabled="{Binding Source={StaticResource Locator}, Path=Settings.IsEditingProjectUser}" IsChecked="{Binding IsGuest, Mode=TwoWay}" Content="Guest" Margin="0,0,8,0" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="70" Style="{StaticResource DefaultRadioButton}"/>
                    <RadioButton IsEnabled="{Binding Source={StaticResource Locator}, Path=Settings.IsEditingProjectUser}" IsChecked="{Binding IsMember, Mode=TwoWay}" Content="Member" Margin="0,0,8,0" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="1" Width="80" Style="{StaticResource DefaultRadioButton}"/>
                    <RadioButton IsEnabled="{Binding Source={StaticResource Locator}, Path=Settings.IsEditingProjectUser}" IsChecked="{Binding IsOwner, Mode=TwoWay}" Content="Owner" Margin="0,0,-1,0" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="2" Width="80" Style="{StaticResource DefaultRadioButton}"/>
                </StackPanel>

            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="DataTemplateMembershipRequest">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" MinWidth="0"/>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="75"/>
                    <ColumnDefinition Width="81"/>
                </Grid.ColumnDefinitions>
                <TextBlock Margin="0,0,2,0" TextWrapping="Wrap" Text="{Binding User, StringFormat=\{0\} has requested membership as}" VerticalAlignment="Center"/>
                <Button Content="Accept" Command="{Binding Source={StaticResource Locator}, Path=Settings.AcceptRequest}" CommandParameter="{Binding}" Grid.Column="2" Margin="4,0" VerticalAlignment="Center"/>
                <Button Content="Reject" Grid.Column="3" Margin="4,0,0,0" VerticalAlignment="Center" Command="{Binding Source={StaticResource Locator}, Path=Settings.RejectRequest}" CommandParameter="{Binding}" />
                <TextBlock Grid.Column="1" Margin="0,0,4,0" TextWrapping="Wrap" Text="{Binding RoleType}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
            </Grid>
        </DataTemplate>
    </sdk:Page.Resources>
    <sdk:Page.FontSize>
        <StaticResource ResourceKey="ContentFontSize"/>
    </sdk:Page.FontSize>
    <sdk:Page.FontFamily>
        <StaticResource ResourceKey="AppFontFamily"/>
    </sdk:Page.FontFamily>

    <Grid x:Name="LayoutRoot" Margin="8" Background="{StaticResource WindowBackground}">
        <sdk:TabControl x:Name="tabControl1" TabStripPlacement="Left" Background="{x:Null}">
            <sdk:TabItem Header="GENERAL" x:Name="tabItem1" DataContext="{Binding Project}" VerticalAlignment="Top">
                <Grid Margin="8,0,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="200" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10"/>
                    </Grid.RowDefinitions>
                    <Rectangle Fill="{StaticResource ControlBackground}" HorizontalAlignment="Left" Height="293" Grid.RowSpan="4" StrokeThickness="1" VerticalAlignment="Top" Width="516"/>
                    <TextBlock HorizontalAlignment="Left" Margin="8,0,0,8" x:Name="textBlock1" Text="{Binding Entity.Name, FallbackValue=HelloWorld}" VerticalAlignment="Center" FontSize="24" Grid.Row="0" />
                    <TextBlock x:Name="textBlock2" Text="Description" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,8,0,0" />
                    <TextBox Grid.Row="2" Margin="8,4,0,4" x:Name="textBox1" Width="500" Text="{Binding Entity.Description, Mode=TwoWay}" TextWrapping="Wrap" IsReadOnly="{Binding IsEditing, Converter={StaticResource NegateConverter}}" HorizontalAlignment="Left" VerticalScrollBarVisibility="Auto" />
                    <StackPanel Margin="433,0,0,0" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                        <Button ToolTipService.ToolTip="Edit" HorizontalAlignment="Center" Margin="0" x:Name="button1" VerticalAlignment="Center" Command="{Binding Edit}" Style="{StaticResource IconButton}" >
                            <Image Stretch="None" Source="Images/Icons/Edit.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                        <Button ToolTipService.ToolTip="CANCEL" HorizontalAlignment="Left" Margin="8,0,0,0" x:Name="button3" VerticalAlignment="Top" Command="{Binding CancelEdit}" Style="{StaticResource IconButton}" >
                            <Image Stretch="None" Source="Images/Icons/Cancel.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                        <Button ToolTipService.ToolTip="Save" HorizontalAlignment="Left" x:Name="button2" VerticalAlignment="Top" Command="{Binding Save}" Style="{StaticResource IconButton}" Margin="4,0,0,0">
                            <Image Stretch="None" Source="Images/Icons/Save.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                    </StackPanel>
                    <CheckBox Content="Public" HorizontalAlignment="Left" Margin="8,4,0,4" Grid.Row="3" VerticalAlignment="Center" IsChecked="{Binding Entity.IsPublic, Mode=TwoWay}" IsEnabled="{Binding IsEditing}" />
                </Grid>
            </sdk:TabItem>
            <sdk:TabItem Header="IMPORT/EXPORT"  VerticalAlignment="Top">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="114"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock HorizontalAlignment="Left" Margin="10,11,0,10" TextWrapping="Wrap" Text="Import" VerticalAlignment="Center" FontSize="{StaticResource HeaderFontSize}" Height="28" Width="64"/>
                    <TextBlock HorizontalAlignment="Left" Height="88" Margin="10,0,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="385">
                    	<Run Text="Data can be imported through a simple tab delimited text file. A text file template and an Excel template can be downloaded via the links below. The import process"/>
                    	<Run Text=" "/>
                    	<Run Text="allows to auto create families, species, and databases. Or can validate against "/>
                    	<Run Text="your "/>
                    	<Run Text="existing "/>
                    	<Run Text="project "/>
                    	<Run Text="structure."/>
                    	<Run Text=" "/>
                    </TextBlock>
                    <HyperlinkButton Content="Text Import Template" HorizontalAlignment="Left" Margin="10,5,0,0" Grid.Row="2" VerticalAlignment="Center" Height="20" Width="144"/>
                    <HyperlinkButton Content="Excel Import Template" HorizontalAlignment="Left" Margin="170,5,0,0" Grid.Row="2" VerticalAlignment="Center" Height="20" Width="149"/>
                    <Button Content="Start New Import" Grid.Row="3" HorizontalAlignment="Left" Margin="10,5,0,5" Width="130" Command="{Binding Import, Mode=OneWay}"/>
                    <TextBlock HorizontalAlignment="Left" Margin="10,0,0,10" TextWrapping="Wrap" Text="Export" VerticalAlignment="Bottom" FontSize="{StaticResource HeaderFontSize}" Height="28" Width="64" Grid.Row="4"/>
                    <TextBlock HorizontalAlignment="Left" Height="88" Margin="10,10,0,0" Grid.Row="5" TextWrapping="Wrap" VerticalAlignment="Top" Width="385" Text="Coming soon..."/>
                </Grid>

            </sdk:TabItem>
            <sdk:TabItem Header="DATABASES" x:Name="tabItem2" VerticalAlignment="Top">
                <Grid>
                    <sdk:DataGrid AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="8,28,0,8" x:Name="listBox1" Width="500" ItemsSource="{Binding FishingDbs}"  >
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn IsReadOnly="true" Header="Name" Binding="{Binding Name}" />
                            <sdk:DataGridTextColumn IsReadOnly="true" Header="Version" Binding="{Binding Version}" />
                            <sdk:DataGridTextColumn IsReadOnly="true" Header="Collection" Binding="{Binding Collection}" />
                            <sdk:DataGridTemplateColumn Header="Enabled">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsEnabled="{Binding Settings.IsEditingFishingDbs, Source={StaticResource Locator}}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" />
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                    <StackPanel Margin="437,3,0,0" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
                        <Button ToolTipService.ToolTip="Edit" HorizontalAlignment="Center" Margin="0" x:Name="button8" VerticalAlignment="Center" Command="{Binding EditFishingDbs}" Style="{StaticResource IconButton}" >
                            <Image Stretch="None" Source="Images/Icons/Edit.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                        <Button ToolTipService.ToolTip="CANCEL" HorizontalAlignment="Left" Margin="8,0,0,0" x:Name="button11" VerticalAlignment="Top" Command="{Binding CancelEditFishingDbEdit}" Style="{StaticResource IconButton}" >
                            <Image Stretch="None" Source="Images/Icons/Cancel.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                        <Button ToolTipService.ToolTip="Save" HorizontalAlignment="Left" x:Name="button12" VerticalAlignment="Top" Command="{Binding SaveFishingDbs}" Style="{StaticResource IconButton}" Margin="4,0,0,0">
                            <Image Stretch="None" Source="Images/Icons/Save.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                    </StackPanel>
                    <TextBlock Text="Fishing databases" Margin="8,4,0,584" HorizontalAlignment="Left" />
                </Grid>
            </sdk:TabItem>
            <sdk:TabItem Header="USERS" x:Name="tabItem3" VerticalAlignment="Bottom" >

                <Grid x:Name="gridProjectDetails" HorizontalAlignment="Left" Margin="0"  >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>

                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>

                    </Grid.RowDefinitions>
                    <TextBlock Text="Project Member" Margin="8,4,0,4" HorizontalAlignment="Left" />
                    <ScrollViewer Grid.Row="1" HorizontalAlignment="Left" Margin="8,0,9,8" Width="500" >
                        <ItemsControl   ItemsSource="{Binding ProjectUser}" ItemTemplate="{StaticResource DataTemplateProjectUser}" ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="0"  />
                    </ScrollViewer>

                    <TextBlock Grid.Row="2" HorizontalAlignment="Left" Margin="8,8,0,4" TextWrapping="Wrap" Text="Membership requests" VerticalAlignment="Center"/>
                    <ScrollViewer Grid.Row="3" Width="500" HorizontalAlignment="Left" Margin="8,0,0,8" >
                        <ItemsControl ItemsSource="{Binding MembershipRequests}" ItemTemplate="{StaticResource DataTemplateMembershipRequest}" ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="0,0,0,8" />
                    </ScrollViewer>

                    <TextBlock HorizontalAlignment="Left" Margin="182,91,0,91" Grid.Row="3" TextWrapping="Wrap" Text="No pending requests" VerticalAlignment="Center" Opacity="0.5" Visibility="{Binding HasMembershipRequests, Converter={StaticResource VisibilityConverter}, ConverterParameter=negate, Mode=OneWay}"/>
                    <StackPanel Margin="0,0,8,0" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                        <Button ToolTipService.ToolTip="Edit" HorizontalAlignment="Center" Margin="0" x:Name="button4" VerticalAlignment="Center" Command="{Binding EditProjectUser}" Style="{StaticResource IconButton}" >
                            <Image Stretch="None" Source="Images/Icons/Edit.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                        <Button ToolTipService.ToolTip="CANCEL" HorizontalAlignment="Left" Margin="8,0,0,0" x:Name="button9" VerticalAlignment="Top" Command="{Binding CancelEditProjectUser}" Style="{StaticResource IconButton}" >
                            <Image Stretch="None" Source="Images/Icons/Cancel.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                        <Button ToolTipService.ToolTip="Save" HorizontalAlignment="Left" x:Name="button10" VerticalAlignment="Top" Command="{Binding SaveProjectUser}" Style="{StaticResource IconButton}" Margin="4,0,0,0">
                            <Image Stretch="None" Source="Images/Icons/Save.png" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Button>
                    </StackPanel>
                </Grid>
            </sdk:TabItem>
        </sdk:TabControl>
    </Grid>
</sdk:Page>
